/**
 * 
 */
package kr.co.insoft.core.repository.comparison.monthly.impl;

import java.util.List;

import kr.co.insoft.core.mapper.comparison.monthly.MonthlyMapper;
import kr.co.insoft.core.model.comparison.monthly.MonthlyEntityModel;
import kr.co.insoft.core.model.comparison.monthly.MonthlyResultEntityModel;
import kr.co.insoft.core.repository.comparison.monthly.MonthlyRepository;
import kr.co.insoft.framework.exceptions.ExceptionCode;
import kr.co.insoft.framework.exceptions.RepositoryException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.util.Assert;

/**
 * @author IN-SOFT Inc. Park Jong Taek(jtpark@in-soft.co.kr)
 * 
 */
@Repository
public class MonthlyRepositoryImpl implements MonthlyRepository {
	
	@Autowired
	MonthlyMapper monthlyMapper;
	
	/**
	 * Script Paging 목록 / pagingModel 검증
	 * 
	 * @param pagingModel
	 * @return
	 * @throws RepositoryException
	 */
	public List<MonthlyResultEntityModel> getChartData(MonthlyEntityModel monthlyEntityModel)
			throws RepositoryException {
		try {
			Assert.notNull(monthlyEntityModel);
			Assert.notNull(monthlyEntityModel.getFromDate());
			Assert.notNull(monthlyEntityModel.getToDate());
		} catch (IllegalArgumentException e) {
			throw new RepositoryException(ExceptionCode.ARGUMENT_ERROR);
		}
		try {
			return monthlyMapper.getChartData(monthlyEntityModel);
		} catch (Exception e) {
			throw new RepositoryException(ExceptionCode.REPOSITORY_EXCEPTION, e);
		}
	}
	
	

}
